//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: RelationsNotificationEventArgs.cs
//
//  Description: EventArgs used in the IRelationsNotification interface.
// 
//--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using Chili.Opf3.Relations;

namespace Chili.Opf3
{
	/// <summary>
	/// EventArgs used in the
	/// <see cref="Opf3.IRelationsNotification">IRelationsNotification</see> interface.
	/// </summary>
	/// <remarks>
	/// This EventArgs class is used by the
	/// <see cref="Opf3.IRelationsNotification">IRelationsNotification</see> interface to send
	/// additional event data. The data that is passed contains the
	/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation. The type of the
	/// current relationship (<see cref="PersistRelationships">PersistRelationships</see>) and the
	/// current operation on the persistent (<see cref="PersistentOperations">PersistentOperations</see>) that
    /// holds the relation.
	/// </remarks>
	[Serializable]
	public sealed class RelationsNotificationEventArgs : EventArgs
	{
		private PersistRelationships _persistRelationship;
		private PersistentOperations _currentOperation;
		private ObjectContext _context;

		/// <summary>
		/// Creates a new instance of the <see cref="RelationsNotificationEventArgs">RelationsNotificationEventArgs Class</see>.
		/// </summary>
		/// <param name="context">The <see cref="ObjectContext">ObjectContext</see> of the current operation.</param>
		/// <param name="persistRelationship">Specifies the relationship between the parent and the related objects.</param>
		/// <param name="currentOperation">Specifies the current operation on the parent persistent object.</param>
		internal RelationsNotificationEventArgs(ObjectContext context, PersistRelationships persistRelationship, PersistentOperations currentOperation)
		{
			if (context == null)
				throw new ArgumentNullException("context");

			_context = context;
			_persistRelationship = persistRelationship;
			_currentOperation = currentOperation;
		}

		/// <summary>
		/// Returns the <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </summary>
		/// <value><see cref="ObjectContext">ObjectContext</see> of the current operation.</value>
		public ObjectContext Context
		{
			get { return _context; }
		}

		/// <summary>
		/// Returns the <see cref="PersistRelationship">PersistRelationship</see> between the parent and the
		/// related objects.
		/// </summary>
		public PersistRelationships PersistRelationship
		{
			get { return _persistRelationship; }
		}

		/// <summary>
		/// Returns the <see cref="PersistentOperations">current operation</see> that is executed on the 
		/// persistent object that holds the relation.
		/// </summary>
		public PersistentOperations PersistentOperation
		{
			get { return _currentOperation; }
		}
	}
}
